package com.sinosoft.jwjw.component.controller;

import com.github.pagehelper.PageInfo;
import com.sinosoft.jwjw.component.model.DepartMentUser;
import com.sinosoft.jwjw.component.service.DepartMentUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value = "/user")
public class DepartMentUserController {
    @Autowired
    private DepartMentUserService departMentUserService;

    @ResponseBody
    @RequestMapping(value = "/")
    public String index(){
        return  "ok";
    }


    @ResponseBody
    @RequestMapping(value = "/all/{pageNum}/{pageSize}", produces = {"application/json;charset=UTF-8"})
    public List<DepartMentUser> findAllDepartMentUser(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize){
        return  departMentUserService.findAllUser(pageNum,pageSize);
    }


    @ResponseBody
    @RequestMapping(value = "/allPage/{pageNum}/{pageSize}", produces = {"application/json;charset=UTF-8"})
    public PageInfo<DepartMentUser> findAllDepartMentUserByPage(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize){
        List<DepartMentUser> list =departMentUserService.findAllUser(pageNum,pageSize);
        return  new PageInfo (list) ;
    }

}
